import cv2
import json

def get_point(key_points, index):
    return (int(key_points[index*3]), int(key_points[index*3+1]))

def add_kp_to_cloth(id):
    img = cv2.imread('./cloth/0'+id+'_cloth.jpg', cv2.IMREAD_UNCHANGED)

    with open("./cloth/0"+id+".json") as f:
        line = f.readline()
        json_obj = json.loads(line)
        keypoints = json_obj["keypoints"]

    points = []
    points.append(get_point(keypoints, 0))
    points.append(get_point(keypoints, 1))
    points.append(get_point(keypoints, 2))
    points.append(get_point(keypoints, 3))
    points.append(get_point(keypoints, 4))
    points.append(get_point(keypoints, 5))

    for point in points:
        cv2.circle(img, point, 1, (0, 255, 0), 2)

    cv2.imwrite("./cloth/0"+id+"_cloth_with_kp.jpg",img)

if __name__=="__main__":
    for i in range(1,6):
        add_kp_to_cloth(str(i))
        